import request from '@/config/axios'
import type { Name } from './types'

export const getNamesListApi = (params: any): Promise<IResponse> => {
  return request.get({ url: '/names', params })
}

export const createNamesApi = (data: Partial<Name>): Promise<IResponse> => {
  return request.post({ url: '/names', data })
}

export const updateNamesApi = (id: string, data: Partial<Name>): Promise<IResponse> => {
  return request.put({ url: `/names/id/${id}`, data })
}

export const getNamesDetailApi = (id: string): Promise<IResponse<Name>> => {
  return request.get({ url: `/names/id/${id}` })
}

export const getNamesByMobileApi = (mobile: string): Promise<IResponse<Name>> => {
  return request.get({ url: `/names/mobile/${mobile}` })
}

export const delNamesListApi = (ids: string[] | number[]): Promise<IResponse> => {
  return request.delete({ url: `/names/id/${ids[0]}` })
}
